package cn.singno.bob.coffice.bean;

import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.apache.poi.ss.usermodel.Workbook;

import cn.singno.bob.bean.OfficeDocument;

/**
 * <p>名称：ExecleView.java</p>
 * <p>描述：Execle表格对象</p>
 * <pre>
 *    
 * </pre>
 * @author 鲍建明
 * @date 2014年8月6日 上午11:19:55
 * @version 1.0.0
 */
public class ExecleDocument  implements Serializable, OfficeDocument{

	/**
	 * 
	 */
	private static final long serialVersionUID = -3198566585406085927L;
	
	/**
	 * 工作薄名称
	 */
	private String tableName;
	
	/**
	 * 表格的标题
	 */
	private String tableTitle;
	
	/**
	 * 表格的导航
	 */
	private List<String> headers;
	
	/**
	 * 表格的内容体
	 */
	private Collection<?> beans;
	
	/**
	 * 表格中图片的宽
	 */
	private Integer imgWidth;
	
	/**
	 * 表格中图片的高
	 */
	private Integer imgHeight;
	
	/**
	 * 表格中日期的格式化
	 */
	private String pattern = "yyyy-MM-dd";
	
	/**
	 * execle对象
	 */
	private Workbook workbook;

	
	
	

	public ExecleDocument() {
		super();
	}

	public ExecleDocument(String tableName, String tableTitle,
			List<String> headers, Collection<?> beans, Integer imgWidth,
			Integer imgHeight) {
		super();
		this.tableName = tableName;
		this.tableTitle = tableTitle;
		this.headers = headers;
		this.beans = beans;
		this.imgWidth = imgWidth;
		this.imgHeight = imgHeight;
	}

	public ExecleDocument(String tableName, String tableTitle,
			List<String> headers, Collection<?> beans) {
		super();
		this.tableName = tableName;
		this.tableTitle = tableTitle;
		this.headers = headers;
		this.beans = beans;
	}

	public ExecleDocument(String tableName, String tableTitle,
			List<String> headers, Collection<?> beans, Integer imgWidth,
			Integer imgHeight, String pattern) {
		super();
		this.tableName = tableName;
		this.tableTitle = tableTitle;
		this.headers = headers;
		this.beans = beans;
		this.imgWidth = imgWidth;
		this.imgHeight = imgHeight;
		this.pattern = pattern;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public List<String> getHeaders() {
		return headers;
	}

	public void setHeaders(List<String> headers) {
		this.headers = headers;
	}

	public Collection<?> getBeans() {
		return beans;
	}

	public void setBeans(Collection<?> beans) {
		this.beans = beans;
	}


	public Integer getImgWidth() {
		return imgWidth;
	}

	public void setImgWidth(Integer imgWidth) {
		this.imgWidth = imgWidth;
	}

	public Integer getImgHeight() {
		return imgHeight;
	}

	public void setImgHeight(Integer imgHeight) {
		this.imgHeight = imgHeight;
	}

	public String getPattern() {
		return pattern;
	}

	public void setPattern(String pattern) {
		this.pattern = pattern;
	}

	public String getTableTitle() {
		return tableTitle;
	}

	public void setTableTitle(String tableTitle) {
		this.tableTitle = tableTitle;
	}

	@Override
	public void write(OutputStream out) throws IOException {
		Workbook wk = getWorkbook();
		if( wk == null){
			throw new IOException("Execle工作薄为空");
		}
		wk.write(out);
	}

	public Workbook getWorkbook() {
		return workbook;
	}

	public void setWorkbook(Workbook workbook) {
		this.workbook = workbook;
	}


}
